package ucm;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import model.Database_Model;
import view.Air_User;

public class UCUpdateReserve {

    private String[] airinformation;
    private Air_User air;

    public UCUpdateReserve(Air_User air) {
        this.air = air;
    }

    public String[] run(){
        try{
            Connection con = new Database_Model().getConnection();
            Statement stmt = con.createStatement();
            ResultSet res = stmt.executeQuery("select * from orders");
            if (res.first()&&!res.wasNull()) {
                res.last();
                airinformation = new String[res.getRow()];
                res.beforeFirst();
                int count = 0;
                while(res.next()){
                    airinformation[count] = res.getString("Name") + ";" + res.getString("Airline") + ";" +
                            res.getString("Pay");
                    System.out.println(airinformation[count]);
                    count ++;
                }
            } else {
                airinformation = null;
            }
        }catch(Exception e){
            e.printStackTrace();
            airinformation = null;
        }

        return airinformation;
    }
}
